
#include <iostream>
#include "SerialStream.h"
#include <unistd.h>

using namespace LibSerial;

int main()
{
   /**
     * Create and open the serial port for communication.
     */
    SerialStream my_serial("/dev/ttyUSB0",std::ios_base::in | std::ios_base::out);

   /**
    * The various available baud rates are defined in SerialStreamBuf 
    * class. This is to be changed soon. All serial port settings will 
    * be placed in in the SerialPort class.
    */
    my_serial.SetBaudRate( SerialStreamBuf::BAUD_128000 ) ;
    
   /**
    * Use 8 bit wide characters.
    */
    my_serial.SetCharSize( SerialStreamBuf::CHAR_SIZE_8 ) ;
    
   /**
    * Use one stop bit.
    */
    my_serial.SetNumOfStopBits(1) ;   
    
   /**
    * Use odd parity during serial communication.
    */
    my_serial.SetParity( SerialStreamBuf::PARITY_NONE ) ;

   /**
    * Use hardware flow-control.
    */
    my_serial.SetFlowControl( SerialStreamBuf::FLOW_CONTROL_NONE ) ;
    

   /**
    * Movement Test
    */
    char output_buffer[10]={0xff,0xfe,
							0x1,
							0x7,0x48,
							0x1,0xc,
							0x0,0x2c,
							0x00};
    my_serial.write( output_buffer, 10);
    
    sleep(3);
    char output_buffer[10]={0xff,0xfe,
							0x1,
							0x0,0x0,
							0x0,0x0,
							0x0,0x0,
							0x00};
    my_serial.write( output_buffer, 10);
    
    /***/
    /**
     * Close serial port.
     */                        
    my_serial.Close() ;
    
    return 0;
}
